# @configure_input@

# Package-related substitution variables
package        = @PACKAGE_NAME@
version        = @PACKAGE_VERSION@
tarname        = @PACKAGE_TARNAME@
distdir        = $(tarname)-$(version)

# Prefix-related substitution variables
prefix         = @prefix@
exec_prefix    = @exec_prefix@
bindir         = @bindir@
datarootdir    = @datarootdir@
pythondir      = @pyexecdir@

# Feature-related variables
local_enable   = @LOCAL_ENABLE@

# Defines the rule to get __init__py from __init__.py.in
ifeq ($(local_enable),yes)
edit = sed -e \
's|@datarootdir[@]/@PACKAGE_TARNAME[@]-@PACKAGE_VERSION[@]/|$(package)Info/|g' \
-e 's|@PACKAGE_NAME[@]|$(package)|g' \
-e 's|@PACKAGE_VERSION[@]|$(version)|g'
else
edit = sed \
-e 's|@datarootdir[@]|$(datarootdir)|g' \
-e 's|@prefix[@]|$(prefix)|g' \
-e 's|@PACKAGE_NAME[@]|$(package)|g' \
-e 's|@PACKAGE_TARNAME[@]|$(tarname)|g' \
-e 's|@PACKAGE_VERSION[@]|$(version)|g'
endif

all : Makefile XmlCppClassGenerator/__init__.py

Makefile: Makefile.in config.status
	./config.status $@

XmlCppClassGenerator/__init__.py : Makefile clean
	rm -f $@ $@.tmp
	srcdir=''; test -f ./$@.in || srcdir=$(srcdir)/;
	$(edit) $${srcdir}$@.in >$@.tmp
	chmod 664 $@.tmp
	mv $@.tmp $@

config.status: configure
	./config.status --recheck

$(datarootdir)/$(distdir) :
	mkdir $(datarootdir)/$(distdir)

$(pythondir)/$(package) :
	mkdir $(pythondir)/$(package)

clean :
	rm -f XmlCppClassGenerator/__init__.py

install : $(datarootdir)/$(distdir) $(pythondir)/$(package)	\
XmlCppClassGenerator/__init__.py
	python -m compileall XmlCppClassGeneratorInfo/
	python -O -m compileall XmlCppClassGeneratorInfo/
	cp XmlCppClassGeneratorInfo/* $(datarootdir)/$(distdir)/
	cp XmlCppClassGenerator/*.py $(pythondir)/$(package)/
	cp GenerateFiles.py $(bindir)/
	chmod 644 $(datarootdir)/$(distdir)/*
	chmod 644 $(pythondir)/$(package)/*

uninstall : clean
	rm -rf $(datarootdir)/$(distdir)/
	rm -rf $(pythondir)/$(package)/
	rm -f $(bindir)/GenerateFiles.py

docclean :
	rm -f Documentation/warning-doxygen.log
	rm -rf Documentation/latex/*
#rm -fr Documentation/html/*

documentation : docclean
	cd Documentation ; \
	doxygen DoxyFile ; \
	cd latex ; \
	make

# Checks that translations files are correct
validity :
	xmllint --noout --schema XmlCppClassGeneratorInfo/Languages.xsd XmlCppClassGeneratorInfo/Translations.xml
	xmllint --noout --schema XmlCppClassGeneratorInfo/Statements.xsd XmlCppClassGeneratorInfo/Bodies.xml

# Builds a tar.bz2 from the package. First checks if the translations
# files are correct.
release : clean docclean validity
	tar -cjf $(package)-$(version).tar.bz2				\
	XmlCppClassGenerator/*.{py,in}					\
	XmlCppClassGeneratorInfo/*.x{sd,ml} GenerateFiles.py		\
	ChangeLog configure COPYING INSTALL install-sh Makefile.in	\
	missing NEWS README Documentation/DoxyFile Documentation/html	\
	Documentation/latex